<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:ui="http://java.sun.com/jsf/facelets">

	<h:head>
		<title></title>
		<link type="text/css" href="#{facesContext.externalContext.request.contextPath}/estilo.css" rel="stylesheet" />
	
		<script>
			var clique;
			function isClique()
			{
				if(clique == null)
					clique = true;
				if(clique){
					barra.show();
					clique = false;
				}
				else{
					barra.hide();
					clique = true;
				}
			}
		</script>
	</h:head>
	<h:body>
		<div id="grid">
		
		
		<div id="banner">
			<ui:insert name="banner">
			</ui:insert>
			
			<p:outputPanel id="sair" rendered="#{not empty facesContext.externalContext.userPrincipal.name}">
				<p:graphicImage height="30" width="30"
								value="#{loginManagedBean.usuario.fotoPerfil != null ? loginManagedBean.foto : '/img/desconhecido.png'}" style="margin-top: -7px;"/>
								
				<h:outputText value="#{loginManagedBean.usuario.login}" />
				<h:outputLink value="#{facesContext.externalContext.request.contextPath}/logoff.jsf">
					<h:outputText value=" (#{msg.sair})" />
				</h:outputLink>			
			</p:outputPanel>
			
			<p:outputPanel id="help" rendered="#{not empty facesContext.externalContext.userPrincipal.name}">
				<div style="height:30px;width:50px;float:right;padding-right:30px">
					<h:outputLink value="#{facesContext.externalContext.request.contextPath}/help.jsf" >
						<h:outputText value="#{msg.help}"/>
					</h:outputLink>
				</div>
			</p:outputPanel>
			
			<p:outputPanel id="flags" rendered="#{not empty facesContext.externalContext.userPrincipal.name}">
				<div style="height:30px;width:80px;float:right;padding-right:30px">
					<h:form>
						<p:commandLink  actionListener="#{localeManagedBean.portugueseLocale}" update="@all">
							<h:graphicImage value="/img/flag-brasil.png" style="width:30px;height:30px">
								<f:view locale="#{localeManagedBean.currentLocale}"
									contentType="text/html; charset=UTF-8" encoding="UTF-8">
								</f:view> 
							</h:graphicImage>
						</p:commandLink>
						<p:commandLink  actionListener="#{localeManagedBean.englishLocale}" update="@all">
							<h:graphicImage value="/img/flag-eua.png" style="width:30px;height:30px">
								<f:view locale="#{localeManagedBean.currentLocale}"
									contentType="text/html; charset=UTF-8" encoding="UTF-8">
								</f:view> 
							</h:graphicImage>
						</p:commandLink>
					</h:form>
				</div>
			</p:outputPanel>
			
			
			<div id="novidades"  style="height:30px;width:150px;float:right;padding-right:60px;">
				<h:form rendered="#{not empty facesContext.externalContext.userPrincipal.name}">
					<p:commandButton action="#{mensagemManagedBean.notificationMensagens}" value="+ #{msg.notificacoes}" 
					onclick="isClique()"
					style="height:30px;width:135px;float:right;font-size:13px;" styleClass="btn"
					update="qtdeNotification" />  
					
					<p:notificationBar  id="notification" position="bottom" effect="slide" widgetVar="barra" styleClass="top" style="top:30px;opacity:0.8;background:#3f4c6b">
						<center>
							<p:panel id="qtdeNotification" rendered="#{not empty facesContext.externalContext.userPrincipal.name}">
		    					<h:outputText value="#{mensagemManagedBean.quantidadeNovasMensagens==0 ? msg.mensagemNotification 
		    										 : (mensagemManagedBean.quantidadeNovasMensagens==1 ? msg.mensagemUmaNotification
		    										 : msg.mensagemPossui.concat(' ').concat(mensagemManagedBean.quantidadeNovasMensagens).concat(' ').concat(msg.mensagemNovas))}"
		    								  rendered="#{loginManagedBean.usuario.qtdWarns==0 or loginManagedBean.usuario.qtdWarns==1 or loginManagedBean.usuario.qtdWarns==2}" style="color:white;font-size:36px;" />
		    					<p:separator/>
		    					
		    					<h:outputText value="#{loginManagedBean.usuario.qtdWarns==0 ? msg.nenhumWarn :''}" style="color:white;"/>
		    					<h:outputText value="#{loginManagedBean.usuario.qtdWarns==1 ? msg.umWarn :''}" style="color:white;"/>
		    					<h:outputText value="#{loginManagedBean.usuario.qtdWarns==2 ? msg.doisWarns :''}" style="color:white;"/>
		    					<h:outputText value="#{loginManagedBean.usuario.qtdWarns>2 and loginManagedBean.usuario.qtdWarns!=7 ? msg.suspenso :''}" style="color:white;" />
		    					<h:outputText value="#{loginManagedBean.usuario.qtdWarns>2 and loginManagedBean.usuario.qtdWarns!=7 ? loginManagedBean.usuario.dataAcesso : ''}" style="color:white;"><f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="#{initParam.timezone}"/></h:outputText>
		    					<h:outputText value="#{loginManagedBean.usuario.qtdWarns==7 ? msg.banido :''}" style="color:white;"/> 
		    			 				
			    			</p:panel>
		    			</center>   
					</p:notificationBar>  
				</h:form>
			</div>
			
				<div id="banner_titulo">
					<h:form>
						<h:commandLink action="#{loginManagedBean.index}" actionListener="#{loginManagedBean.acionaLinhaDoTempo}" rendered="#{not empty facesContext.externalContext.userPrincipal.name}">UCBLive</h:commandLink>
						<h:outputLink value="index.jsf" rendered="#{empty facesContext.externalContext.userPrincipal.name}">UCBLive</h:outputLink>
					</h:form>
				</div>
			
		</div>
		
		<div id="conteudo">
			<ui:insert name="conteudoPrincipal">
				<div id="conteudo_esq">
					<h3> <p:outputLabel value="#{msg.menu}"/> </h3>
					<ui:insert name="menu">
	            	</ui:insert>	
						<h:form rendered="#{loginManagedBean != null}">
							
							<p:outputPanel rendered="#{loginManagedBean.usuario.tipo==4}"> 
								<ul id="menuAdm">
									<li>
										<h:commandLink value="#{msg.cadastrarUsuario}" action="#{usuarioManagedBean.populaAll}"/>
									</li>
									<li>
										<h:commandLink value="#{msg.cadastrarCurso}" action="#{cursoManagedBean.populaDisciplinas}"/>
									</li>
									<li>
										<h:commandLink value="#{msg.cadastrarDisciplina}" action="#{disciplinaManagedBean.populaCursosProfessores}"/>
									</li>
									<li>
										<h:commandLink value="#{msg.listarUsuario}" action="#{usuarioManagedBean.listarUsuarios}" />
									</li>
									<li>
										<h:commandLink value="#{msg.listarCurso}" action="#{cursoManagedBean.listarCursos}" />   
									</li>
									<li>
										<h:commandLink value="#{msg.listarDisciplina}" action="#{disciplinaManagedBean.listarDisciplinas}"/>
									</li>					
								</ul>
							</p:outputPanel>
							
							<p:outputPanel rendered="#{loginManagedBean.usuario.tipo==1}">
								<ul id="menuMod">
									<li>
										<h:commandLink value="#{msg.cadastrarEvento}" action="#{eventoManagedBean.cadastrarEvento}" />
									</li>
								</ul>
							</p:outputPanel>
							
							<p:outputPanel rendered="#{loginManagedBean.usuario.tipo==1 or loginManagedBean.usuario.tipo==2}">
								<ul id="menuModPro">
									<li>
										<h:commandLink value="#{msg.controleWarns}" action="#{alunoManagedBean.listarAlunos}"/>
									</li>
								</ul>
							</p:outputPanel>
																					 											
							<p:outputPanel rendered="#{loginManagedBean.usuario.tipo!=4 and loginManagedBean.usuario.status==0}"> 
								<ul id="menuAll">		    
									<li>
										<h:commandLink value="#{msg.listarEvento}" action="#{eventoManagedBean.listarEventos}"/>
									</li>	
									<li>
										<h:commandLink value="#{msg.mensagem}" action="#{mensagemManagedBean.populaMensagens}"/>
									</li>
									<li>
										<h:commandLink value="#{msg.perfil}" action="#{usuarioManagedBean.usuarioPerfil}" />
									</li>
									<li>
										<h:commandLink value="#{msg.forum}" action="#{disciplinaManagedBean.listarForuns}"/>
									</li>
								</ul>
							</p:outputPanel>
							
						</h:form>
				</div>
				
				<div id="conteudo_dir">
					<ui:insert name="conteudo">
					</ui:insert>
				</div>		
			</ui:insert>
		</div>
		
		<div id="rodape">
				<ui:insert name="rodape">
				</ui:insert>
		</div>
	</div>
	</h:body>
</html>